package com.atguigu.gulimall.product.entity;

import com.atguigu.common.validator.group.AddGroup;
import com.atguigu.common.validator.group.ListValue;
import com.atguigu.common.validator.group.UpdateGroup;
import com.atguigu.common.validator.group.UpdateStatusGroup;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	// UpdateGroup.class是修改品牌信息
	// UpdateStatusGroup是修改品牌状态信息
	// AddGroup.class 	是添加品牌

	/**
	 * 总结：
	 * 	添加： 不能有brandId， 要有name logo showStatus  firstLetter  sort
	 *
	 * 	修改品牌信息：    要有 name brandId 。可以不写，但是写了要写对：logo  name firstLetter sort
	 *
	 * 	页面修改状态的按钮： 不能空，还要写对： showStatus
	 */
	@NotNull(message = "修改要指定id",groups = {UpdateGroup.class})
	@Null(message = "新增时候不能指定id",groups = {AddGroup.class})
	@TableId
	private Long brandId; // 自增的

	@NotBlank(message = "品牌名必须要提交",groups = {AddGroup.class,UpdateGroup.class})// 可以空。要写就要写对
	private String name; // 字符串用NotBlank ？？

	@NotBlank(groups = {AddGroup.class})
	@URL(message = "logo要合法哦",groups = {AddGroup.class,UpdateGroup.class}) // 可以空。要写就要写对
	private String logo;

	private String descript;

	@NotNull(groups = {AddGroup.class, UpdateStatusGroup.class})
	@ListValue(vals = {0,1},groups = {AddGroup.class, UpdateStatusGroup.class})	 // @ListValue：自定义注解。gulimall_common写着
	private Integer showStatus;

	@NotEmpty(groups = {AddGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$",message = "要写成字母",groups = {AddGroup.class,UpdateGroup.class}) // 可以空。但写了就会检查
	private String firstLetter;

	@NotNull(groups = {AddGroup.class})
	@Min(value = 0,message = "写大于等于 0 数字",groups = {AddGroup.class,UpdateGroup.class})// 可以空。但写了就会检查
	private Integer sort;

}
